package lbh.crawler;

import java.util.ArrayList;
import java.util.List;

public class Subsystem extends Module {

	public Subsystem(Subsystem ss, String name) {
		super(ss, name);
	}

	private List<Module> modules = new ArrayList<>();

	public void addModule(Module m) {

		synchronized (modules) {
			modules.add(m);
		}
	}

	public void removeModule(Module m) {

		synchronized (modules) {
			modules.remove(m);
		}
	}

	public List<Module> getModules() {

		return modules;
	}

	public Module findModule(String name) {

		for (Module m : modules)
			if (m.getName().endsWith(name))
				return m;

		return null;
	}

	@Override
	public String getName() {
		return "subsystem";
	}
}
